#!/bin/bash

# 设置环境变量
export BASE_IP=$VUE_APP_BASE_HOST
export BASE_PORT=$VUE_APP_BASE_PORT
export VEDIO_IP=$VUE_APP_VEDIO_HOST
export VEDIO_PORT=$VUE_APP_VEDIO_PORT
# 使用 Here Document 将配置字符串写入文件
cat <<EOF > /etc/nginx/conf.d/default.conf
server {
  listen 8088;
  listen [::]:8088;
  server_name _;
  root /home/web/frontend;
  index index.html;

  location /api2/ {
    proxy_pass http://$VEDIO_IP:$VEDIO_PORT/;
  }

  location /api/ {
    proxy_pass http://$BASE_IP:$BASE_PORT;
  }
}
EOF

echo "配置文件已创建并写入"
service nginx restart
echo "Frontend launched. Please open your browser"
sleep infinity